package com.bwie.es.sync;

import com.alibaba.fastjson.JSON;
import com.bwie.common.result.Result;
import com.bwie.es.feign.EsFeignService;
//import com.bwie.es.service.EsEmpployeeService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;



@Component
@Log4j2
public class SycnShculd {

//    @Autowired
//    private EsFeignService esFeignService;

//    @Autowired
//    private EsEmpployeeService esEmpployeeService;


//    @Scheduled(cron = "30 * * * * ?")
    public void add(){
        log.info("定时器---->文章从mysql全量同步到es的定时器正在执行,开始查询数据库...");

        // 远程调用  查询返回结果姐的集合列表   getArticleList  拿到数据getData
//        Result<List<Article>> result = esFeignService.getArticleList();
//        List<Article> list = result.getData();
        // log.info("定时器---->文章从mysql全量同步到es的定时器正在执行,mysql查询到的博客数据为:{},开始同步...",
        //         JSON.toJSONString(list));
        try {

            //  mysql全量同步到es  接口调方法
//            esArticleService.insertBatch(list);
            log.info("定时器---->文章从mysql全量同步到es的定时器正在执行,同步成功...");
        } catch (Exception exception) {
            exception.printStackTrace();
            log.error("定时器---->文章从mysql全量同步到es的定时器正在执行,同步失败!"+exception.getMessage());
        }
    }
}
